﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Routing;
using MvcEngine.Core;
using MvcEngine.Core.Repositories;
using MvcEngine.Core.Content;

namespace MvcEngine.Mvc.Constraints
{
    public class UrlConstraint : IRouteConstraint
    {
        #region IRouteConstraint Members

        public bool Match(System.Web.HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            return ContentManager.Current.GetPages(0, 0).Any(p => p.Name == (string)values["pageName"]);
        }

        #endregion
    }
}
